package com.cyzy.controller;

import com.cyzy.dto.Result;
import com.cyzy.dto.ScoreProductListDto;
import com.cyzy.service.ScoreProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/score")
public class ScoreProductController {

    @Autowired
    private ScoreProductService scoreProductService;

    @GetMapping("/list")
    public Result getScoreProductList() {
        try {
            List<ScoreProductListDto> productList = scoreProductService.getScoreProductList();
            return Result.ok().data("productList", productList).message("获取积分商品列表成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error().message("获取积分商品列表失败：" + e.getMessage());
        }
    }

}
